/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "orden_pago", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrdenPago.findAll", query = "SELECT o FROM OrdenPago o"),
    @NamedQuery(name = "OrdenPago.findByIdordenPago", query = "SELECT o FROM OrdenPago o WHERE o.idordenPago = :idordenPago"),
    @NamedQuery(name = "OrdenPago.findByFecha", query = "SELECT o FROM OrdenPago o WHERE o.fecha = :fecha"),
    @NamedQuery(name = "OrdenPago.findByEstado", query = "SELECT o FROM OrdenPago o WHERE o.estado = :estado")})
public class OrdenPago implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idorden_pago", nullable = false)
    private Integer idordenPago;
    @Column(name = "fecha")
    private Integer fecha;
    @Column(name = "estado")
    private Integer estado;
    @JoinTable(name = "orden_pago_cta_pagar_com", joinColumns = {
        @JoinColumn(name = "idorden_pago", referencedColumnName = "idorden_pago", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "idcta_pagar", referencedColumnName = "idcta_pagar", nullable = false),
        @JoinColumn(name = "idcompra_cab", referencedColumnName = "idcompra_cab", nullable = false),
        @JoinColumn(name = "cta_pagar_compra_cab_fecha", referencedColumnName = "compra_cab_fecha", nullable = false),
        @JoinColumn(name = "cta_pagar_compra_cab_nro_factura", referencedColumnName = "compra_cab_nro_factura", nullable = false),
        @JoinColumn(name = "cta_pagar_compra_cab_idproveedores", referencedColumnName = "compra_cab_idproveedores", nullable = false)})
    @ManyToMany
    private Collection<CtaPagar> ctaPagarCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "ordenPago")
    private OrdenPagoSueldoDet ordenPagoSueldoDet;
    @JoinColumn(name = "tipo_documento_tipo_cod", referencedColumnName = "tipo_cod", nullable = false)
    @ManyToOne(optional = false)
    private TipoDocumento tipoDocumentoTipoCod;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenPago")
    private Collection<OrdenPagoDetFondoFijo> ordenPagoDetFondoFijoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenPago")
    private Collection<PagoCheque> pagoChequeCollection;

    public OrdenPago() {
    }

    public OrdenPago(Integer idordenPago) {
        this.idordenPago = idordenPago;
    }

    public Integer getIdordenPago() {
        return idordenPago;
    }

    public void setIdordenPago(Integer idordenPago) {
        this.idordenPago = idordenPago;
    }

    public Integer getFecha() {
        return fecha;
    }

    public void setFecha(Integer fecha) {
        this.fecha = fecha;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<CtaPagar> getCtaPagarCollection() {
        return ctaPagarCollection;
    }

    public void setCtaPagarCollection(Collection<CtaPagar> ctaPagarCollection) {
        this.ctaPagarCollection = ctaPagarCollection;
    }

    public OrdenPagoSueldoDet getOrdenPagoSueldoDet() {
        return ordenPagoSueldoDet;
    }

    public void setOrdenPagoSueldoDet(OrdenPagoSueldoDet ordenPagoSueldoDet) {
        this.ordenPagoSueldoDet = ordenPagoSueldoDet;
    }

    public TipoDocumento getTipoDocumentoTipoCod() {
        return tipoDocumentoTipoCod;
    }

    public void setTipoDocumentoTipoCod(TipoDocumento tipoDocumentoTipoCod) {
        this.tipoDocumentoTipoCod = tipoDocumentoTipoCod;
    }

    @XmlTransient
    public Collection<OrdenPagoDetFondoFijo> getOrdenPagoDetFondoFijoCollection() {
        return ordenPagoDetFondoFijoCollection;
    }

    public void setOrdenPagoDetFondoFijoCollection(Collection<OrdenPagoDetFondoFijo> ordenPagoDetFondoFijoCollection) {
        this.ordenPagoDetFondoFijoCollection = ordenPagoDetFondoFijoCollection;
    }

    @XmlTransient
    public Collection<PagoCheque> getPagoChequeCollection() {
        return pagoChequeCollection;
    }

    public void setPagoChequeCollection(Collection<PagoCheque> pagoChequeCollection) {
        this.pagoChequeCollection = pagoChequeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idordenPago != null ? idordenPago.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdenPago)) {
            return false;
        }
        OrdenPago other = (OrdenPago) object;
        if ((this.idordenPago == null && other.idordenPago != null) || (this.idordenPago != null && !this.idordenPago.equals(other.idordenPago))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.OrdenPago[ idordenPago=" + idordenPago + " ]";
    }
    
}
